Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displays the new licence->name instead of license_account matching licence #7097

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

nicomollet
Copy link
Contributor

Description

Fixes #7096

The PR only changes dashboard view (Your licence) with a fallback:

  • Display the user->licence->name is if exists in the user endpoint
  • Display the regular licence_account matching licence name if user->licence->name is empty

The user endpoint will soon include new values under licence, like name, expiration, type, version.
Until this is the case, this code will just fallback to current way of displaying the license name in the dashboard.

After the new license data is available to the plugin (once service team deploys and repopulate Redis for users), the plugin will have user->licence->name set and then can display it directly.
See the new user endpoint data JSON response format.

Back-compatibility: Users with previous plugin versions will not be able to see their accurate license name. A fallback was made on service side to display Infinite, for new licenses.

image

Type of change

  • New feature (non-breaking change which adds functionality).
  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

A missing licence->name value should not trigger any error and fallback to legacy way to matching the licence name.

See two types of user, one with new license data, one without.

Technical description

Documentation

The new user endpoint JSON format:

{
    "ID": "1",
    "licence": {
        "type": "infinite",
        "name": "Infinite",
        "websites": "-1",
        "version": "3.14.1",
        "expiration": "1793187043"
    },
    "first_name": "Xxx",
    "email": "[email protected]",
    "date_created": "1370596455",
    "licence_account": "-1",
    "licence_version": "3.14.1",
    "licence_expiration": "1793187043",
    "consumer_key": "xxxx",
    "is_blocked": "0",
    "is_staggered": "0",
    "has_auto_renew": "1",
    "has_one-com_account": "0",
    "status": "active",
    "last_order_reseller_id": "0",
    "renewal_url": "https://wp-rocket.me/checkout/renew/xxxx/xxxxxxxxx/",
    "upgrade_plus_url": "https://wp-rocket.me/checkout/upgrade/xxxx/xxxx/plus/",
    "upgrade_infinite_url": "https://wp-rocket.me/checkout/upgrade/xxxx/xxxx/infinite/"
}

Risks

If the license->name is missing, the plugin will behave just as before.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

@nicomollet nicomollet self-assigned this Nov 7, 2024
@nicomollet nicomollet requested review from a team November 7, 2024 13:29
Copy link

codacy-production bot commented Nov 7, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for e5bca661 50.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (e5bca66) Report Missing Report Missing Report Missing
Head commit (709a117) 38132 16704 43.81%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7097) 2 1 50.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@Mai-Saad
Copy link
Contributor

@Mai-Saad
Copy link
Contributor

Mai-Saad commented Nov 14, 2024

@nicomollet Thanks for the PR.
For the user with new license data, checked with the following values for license -1,1,3,50,10,500 and whitelabel.
Screenshot from 2024-11-14 12-58-32
Screenshot from 2024-11-14 12-57-10
Screenshot from 2024-11-14 12-56-46
Screenshot from 2024-11-14 12-56-23
Screenshot from 2024-11-14 12-55-46
Screenshot from 2024-11-14 12-54-11
Screenshot from 2024-11-14 12-45-01

  • used the code snippet here and is reflected correctly too with no error

  • update the wpr from 3.17.2.1 to PR is good

  • rollback is not working there (not sure if we need to do changes in the bash generating the zip or what) @nicomollet can you please check 🙏
    Screenshot from 2024-11-14 13-33-57 Update: Rollback is good after adjusting account license and if license was 500 , after rollback , will be infinite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display accurate licence name, not depending on licence account
4 participants